<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">

	<meta name="viewport"
		content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0">

	<title>领军者后台</title>
	<link rel="stylesheet" href="/public/css/auth.css">
	<script type="text/javascript" src="/public/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/public/js/xadmin.js"></script>
	<script src="/node_modules/jquery/dist/jquery.js"></script>
</head>

<body>
	<div class="lowin lowin-green">
		<a href="/">
			<div class="lowin-brand">
				<img src="/public/img/logo2.png" alt="logo">
			</div>
		</a>

		<div class="lowin-wrapper">
			<div class="lowin-box lowin-login">
				<div class="lowin-box-inner">
					<form id="login_form">
						<p>后台管理</p>
						<div class="lowin-group">
							<label>账号</label>
							<input type="text" autocomplete="text" name="loginname" required="" class="lowin-input"
								lay-verify="required|loginname">
						</div>
						<div class="lowin-group password-group">
							<label>密码</label>
							<input type="password" name="password" required="" autocomplete="current-password"
								id="passwordId" class="lowin-input" lay-verify="pass|password">
						</div>
						<button class="lowin-btn login-btn" type="submit">
							登录
						</button>
					</form>
				</div>
			</div>
		</div>
	</div>
	<script src="/public/js/auth.js"></script>
	<script src="/node_modules/jquery/dist/jquery.js"></script>

	<script>
		$('#login_form').on('submit', function (e) {
			e.preventDefault()
			var formData = $(this).serialize()
			console.log(formData)
			$.ajax({
				url: '/admin',
				type: 'post',
				data: formData,
				dataType: 'json',
				success: function (data) {
					var err_code = data.err_code
					if (err_code === 0) {
						// 服务端重定向针对异步请求无效
						window.location.href = '/index'
					} else if (err_code === 1) {
						layer.alert('账号或者密码错误')
					} else if (err_code === 500) {
						layer.alert('服务器忙，请稍后重试！')
					}
				}
			})
		})
	</script>
	<!-- <script>
			Auth.init({
				login_url: '#login',
				forgot_url: '#forgot'
			});
		</script> -->
</body>

</html>